/*
 * @Author: lp
 * @Date: 2022-03-26 14:20:16
 * @LastEditTime: 2022-04-29 12:00:57
 * @LastEditors: Please set LastEditors
 * @Description: 多语言配置
 * @FilePath: \nien-vue3-admin\src\i18n\index.ts
 */
import { createI18n } from 'vue-i18n/index'
import zhCn from './zhCn'
import en from './en'

const messages = {
  [zhCn.name]: zhCn,  
  [en.name]: en,
}
let locale = 'zh-cn'
const language = localStorage.getItem('language') || navigator.language
if (language.indexOf('zh') != -1) {
  // 浏览器语言是中文
  locale = 'zh-cn'
} else if (language.indexOf('en') != -1) {
  // 浏览器语言是英文
  locale = 'en'
}
// 导出语言国际化
export default createI18n({
  locale,
  fallbackLocale: 'zh-cn',
  messages,
})